//package com.sydata.framework.web.service;
//
//import java.util.concurrent.TimeUnit;
//
//import com.sydata.common.utils.DESencrypt;
//import com.sydata.framework.manager.factory.AsyncFactory;
//import com.sydata.framework.security.context.AuthenticationContextHolder;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.security.core.Authentication;
//import org.springframework.stereotype.Component;
//import com.sydata.common.constant.CacheConstants;
//import com.sydata.common.constant.Constants;
//import com.sydata.common.core.domain.entity.SysUser;
//import com.sydata.common.core.redis.RedisCache;
//import com.sydata.common.exception.user.UserPasswordNotMatchException;
//import com.sydata.common.exception.user.UserPasswordRetryLimitExceedException;
//import com.sydata.common.utils.MessageUtils;
//import com.sydata.common.utils.SecurityUtils;
//import com.sydata.framework.manager.AsyncManager;
//
///**
// * 登录密码方法
// *
// * @author ruoyi
// */
//@Component
//public class SysPasswordService
//{
//    @Autowired
//    private RedisCache redisCache;
//
//    @Value(value = "${user.password.maxRetryCount}")
//    private int maxRetryCount;
//
//    @Value(value = "${user.password.lockTime}")
//    private int lockTime;
//
//    /**
//     * 登录账户密码错误次数缓存键名
//     *
//     * @param username 用户名
//     * @return 缓存键key
//     */
//    private String getCacheKey(String username)
//    {
//        return CacheConstants.PWD_ERR_CNT_KEY + username;
//    }
//
//    public void validate(SysUser user)
//    {
//        Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
//        String username = usernamePasswordAuthenticationToken.getName();
//        String password = usernamePasswordAuthenticationToken.getCredentials().toString();
//
//
//        if (!matches(user, password))
//        {
//            throw new UserPasswordNotMatchException();
//        }
//
//
//
//    }
//
//    public boolean matches(SysUser user, String rawPassword)
//    {
//        return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
//    }
//
////
////    public void clearLoginRecordCache(String loginName)
////    {
////        if (redisCache.hasKey(getCacheKey(loginName)))
////        {
////            redisCache.deleteObject(getCacheKey(loginName));
////        }
////    }
//}
